<html>
<head>
<title>test</title>
<script type="text/javascript" src="js/csv.js"></script>
<script type="text/javascript">
	var turl = "http://rate.bot.com.tw/Pages/UIP004/Download.ashx?lang=en-US&fileType=1";
	//whom=USD&date1=20070901&date2=20071212";
	function formatDate(idate){
		var odate = idate.getFullYear() + '';
		var m = idate.getMonth();
		if(m < 10){
			odate += '0';
		}
		odate += m;
		var d = idate.getDate();
		if(d < 10){
			odate += '0';
		}
		odate += d;
		return odate;
	}
	function getURL(whom, diffdate){
		if(isNaN(diffdate){
			diffdate=14;
		}
		var enddate = new Date();
		var startdate = new Date(enddate.getTime() - diffdate*24*60*60*1000);
		var url1 = turl + "&whom="+whom;
		url1+= "&date1=" + formatDate(startdate);
		url1+= "&date2=" + formatDate(enddate);
		return url1;
	}
	function getData2(durl){
		var req = new XMLHttpRequest();
		req.open('GET', durl, true);
		req.onreadystatechange = function (aEvt) {
			alert(req.readyState);
		  if (req.readyState == 4) {
		     if(req.status == 200){
		      document.getElementById(outdata).value = (req.responseText);
		     }else{
		      alert("Error loading page\n");
		    }
		  }
		};
		req.send(null); 
	}
	function getData(durl){
		document.getElementById("outdata").value = csv2array(testdata);
	}
	var testdata = "Date,Currency,Rate,Cash,Spot,Forward-10Days,Forward-30Days,Forward-60Days,Forward-90Days,Forward-120Days,Forward-150Days,Forward-180Days,Rate,Cash,Spot,Forward-10Days,Forward-30Days,Forward-60Days,Forward-90Days,Forward-120Days,Forward-150Days,Forward-180Days\r\n" +
"20070903, USD, Buying, 32.66500, 32.96500, 32.93900, 32.85100, 32.74700, 32.64300, 32.54500, 32.45700, 32.37500,Selling, 33.20700, 33.06500, 33.04100, 32.97000, 32.86700, 32.76700, 32.66500, 32.57700, 32.50500,\r\n" +
"20070904, USD, Buying, 32.68500, 32.98500, 32.95900, 32.86200, 32.76500, 32.67000, 32.56500, 32.45300, 32.39300,Selling, 33.22700, 33.08500, 33.06100, 32.97800, 32.88300, 32.78000, 32.68500, 32.58200, 32.50500,\r\n" +
"20070905, USD, Buying, 32.68500, 32.98500, 32.95900, 32.86100, 32.76200, 32.65600, 32.56900, 32.45800, 32.38300,Selling, 33.22700, 33.08500, 33.06100, 32.98000, 32.88200, 32.78200, 32.68800, 32.57800, 32.50500,\r\n" +
"20070906, USD, Buying, 32.69000, 32.99000, 32.96400, 32.87300, 32.76000, 32.66500, 32.55500, 32.45000, 32.39500,Selling, 33.23200, 33.09000, 33.06600, 32.99000, 32.88000, 32.78500, 32.67500, 32.57000, 32.51500,\r\n" +
"20070907, USD, Buying, 32.70000, 33.00000, 32.97400, 32.88200, 32.76700, 32.67400, 32.57700, 32.48100, 32.40200,Selling, 33.24200, 33.10000, 33.07600, 33.00200, 32.88700, 32.79400, 32.69700, 32.60100, 32.53200,\r\n" +
"20070910, USD, Buying, 32.71000, 33.01000, 32.98400, 32.89500, 32.78400, 32.68700, 32.58300, 32.49400, 32.39500,Selling, 33.25200, 33.11000, 33.08600, 33.01000, 32.90400, 32.80500, 32.70300, 32.61400, 32.54500,\r\n" +
"20070911, USD, Buying, 32.72500, 33.02500, 33.00000, 32.90500, 32.80300, 32.70200, 32.60300, 32.50900, 32.43700,Selling, 33.26700, 33.12500, 33.10100, 33.02000, 32.92400, 32.82200, 32.72000, 32.62900, 32.54700,\r\n" +
"20070912, USD, Buying, 32.73000, 33.03000, 33.00500, 32.91200, 32.81000, 32.71000, 32.61500, 32.51600, 32.44300,Selling, 33.27200, 33.13000, 33.10700, 33.03000, 32.93000, 32.83000, 32.73500, 32.63600, 32.55500,\r\n" +
"20070913, USD, Buying, 32.73000, 33.03000, 33.00000, 32.91700, 32.80600, 32.71000, 32.61500, 32.52100, 32.43900,Selling, 33.27200, 33.13000, 33.10100, 33.03500, 32.92000, 32.83000, 32.73500, 32.64000, 32.55800,\r\n" +
"20070914, USD, Buying, 32.73000, 33.03000, 33.00400, 32.91900, 32.81200, 32.71100, 32.62000, 32.52300, 32.44000,Selling, 33.27200, 33.13000, 33.10600, 33.03500, 32.93000, 32.83000, 32.74000, 32.64000, 32.56000,\r\n" +
"20070917, USD, Buying, 32.76500, 33.06500, 33.04300, 32.96100, 32.84800, 32.75200, 32.64500, 32.56700, 32.49900,Selling, 33.30700, 33.16500, 33.14400, 33.07500, 32.98200, 32.87200, 32.77500, 32.69700, 32.61500,\r\n" +
"20070918, USD, Buying, 32.77000, 33.07000, 33.04800, 32.96600, 32.85300, 32.75700, 32.65000, 32.57200, 32.50400,Selling, 33.31200, 33.17000, 33.14900, 33.08000, 32.98700, 32.87700, 32.78000, 32.70200, 32.62000,\r\n" +
"20070919, USD, Buying, 32.74000, 33.04000, 33.01900, 32.94000, 32.85000, 32.76900, 32.66500, 32.58500, 32.52900,Selling, 33.28200, 33.14000, 33.12100, 33.06000, 32.97500, 32.88500, 32.79500, 32.71500, 32.64500,\r\n" +
"20070920, USD, Buying, 32.72000, 33.02000, 33.00000, 32.92300, 32.83700, 32.74500, 32.62200, 32.55700, 32.50700,Selling, 33.26200, 33.12000, 33.10200, 33.04200, 32.95500, 32.86500, 32.79200, 32.70300, 32.62000,\r\n" +
"20070921, USD, Buying, 32.60500, 32.90500, 32.88400, 32.80500, 32.72300, 32.63500, 32.54200, 32.46300, 32.40100,Selling, 33.14700, 33.00500, 32.98700, 32.92300, 32.84500, 32.75900, 32.66200, 32.58300, 32.52500,\r\n" +
"20070926, USD, Buying, 32.58000, 32.88000, 32.85900, 32.77500, 32.68800, 32.60100, 32.51100, 32.43500, 32.35500,Selling, 33.12200, 32.98000, 32.96000, 32.89400, 32.80800, 32.72100, 32.63100, 32.55600, 32.48500,\r\n" +
"20070927, USD, Buying, 32.48500, 32.78500, 32.76100, 32.68400, 32.59200, 32.50400, 32.42200, 32.34000, 32.26500,Selling, 33.02700, 32.88500, 32.86300, 32.80400, 32.71200, 32.62400, 32.54200, 32.46000, 32.38500,\r\n" +
"20070928, USD, Buying, 32.32500, 32.62500, 32.60400, 32.52400, 32.43500, 32.34500, 32.25600, 32.18500, 32.10800,Selling, 32.86700, 32.72500, 32.70500, 32.64400, 32.55000, 32.46200, 32.37600, 32.30400, 32.22700,\r\n" +
"20070929, USD, Buying, 32.27000, 32.57000, 32.54900, 32.47000, 32.38000, 32.29100, 32.20300, 32.13000, 32.05500,Selling, 32.81200, 32.67000, 32.65100, 32.59000, 32.50000, 32.41100, 32.32300, 32.25000, 32.17500,\r\n" +
"20071001, USD, Buying, 32.22000, 32.52000, 32.49700, 32.41700, 32.33400, 32.24500, 32.15500, 32.08200, 32.01800,Selling, 32.76200, 32.62000, 32.59800, 32.53500, 32.45400, 32.36500, 32.27500, 32.20200, 32.13200,\r\n" +
"20071002, USD, Buying, 32.23000, 32.53000, 32.50900, 32.43000, 32.34700, 32.25800, 32.17000, 32.10500, 32.02400,Selling, 32.77200, 32.63000, 32.61100, 32.55000, 32.46700, 32.37700, 32.29000, 32.22500, 32.14400,\r\n" +
"20071003, USD, Buying, 32.22500, 32.52500, 32.50400, 32.42700, 32.34300, 32.24500, 32.16900, 32.09500, 32.01700,Selling, 32.76700, 32.62500, 32.60600, 32.54800, 32.46000, 32.36400, 32.28900, 32.21500, 32.13600,\r\n" +
"20071004, USD, Buying, 32.25000, 32.55000, 32.53000, 32.45200, 32.36500, 32.27500, 32.18500, 32.11700, 32.04800,Selling, 32.79200, 32.65000, 32.63100, 32.57200, 32.48500, 32.39500, 32.30500, 32.23700, 32.16200,\r\n" +
"20071005, USD, Buying, 32.25000, 32.55000, 32.52900, 32.45300, 32.36500, 32.27500, 32.18500, 32.11000, 32.04300,Selling, 32.79200, 32.65000, 32.63200, 32.57200, 32.48500, 32.39500, 32.30500, 32.24000, 32.16100,\r\n" +
"20071008, USD, Buying, 32.24000, 32.54000, 32.51900, 32.43800, 32.35500, 32.26800, 32.17900, 32.10800, 32.02500,Selling, 32.78200, 32.64000, 32.62200, 32.55700, 32.47500, 32.38800, 32.29900, 32.22700, 32.14700,\r\n" +
"20071009, USD, Buying, 32.25000, 32.55000, 32.52900, 32.45000, 32.36600, 32.26900, 32.18800, 32.11200, 32.02800,Selling, 32.79200, 32.65000, 32.63100, 32.57000, 32.48500, 32.38900, 32.30800, 32.23200, 32.14800,\r\n" +
"20071011, USD, Buying, 32.23000, 32.53000, 32.50900, 32.43000, 32.33700, 32.25000, 32.16700, 32.08500, 32.01000,Selling, 32.77200, 32.63000, 32.61100, 32.54900, 32.45700, 32.36900, 32.28700, 32.20500, 32.13000,\r\n" +
"20071012, USD, Buying, 32.24000, 32.54000, 32.52000, 32.44100, 32.35000, 32.26200, 32.16500, 32.10400, 32.03200,Selling, 32.78200, 32.64000, 32.62100, 32.56000, 32.47000, 32.38200, 32.29500, 32.22200, 32.15200,\r\n" +
"20071015, USD, Buying, 32.25000, 32.55000, 32.52900, 32.44800, 32.36500, 32.27000, 32.18300, 32.11400, 32.04000,Selling, 32.79200, 32.65000, 32.63100, 32.56400, 32.48500, 32.39000, 32.30300, 32.23700, 32.16000,\r\n" +
"20071016, USD, Buying, 32.26000, 32.56000, 32.53900, 32.46000, 32.37500, 32.28000, 32.19500, 32.12500, 32.05200,Selling, 32.80200, 32.66000, 32.64100, 32.57900, 32.49400, 32.40000, 32.31500, 32.24500, 32.17200,\r\n" +
"20071017, USD, Buying, 32.28000, 32.58000, 32.55900, 32.48300, 32.39500, 32.29200, 32.21800, 32.14500, 32.06700,Selling, 32.82200, 32.68000, 32.66200, 32.60200, 32.51500, 32.41200, 32.33800, 32.26500, 32.18700,\r\n" +
"20071018, USD, Buying, 32.25000, 32.55000, 32.53000, 32.45200, 32.36200, 32.27500, 32.19000, 32.11000, 32.05700,Selling, 32.79200, 32.65000, 32.63200, 32.57100, 32.48200, 32.39500, 32.31000, 32.22900, 32.17700,\r\n" +
"20071019, USD, Buying, 32.22500, 32.52500, 32.50500, 32.43300, 32.34700, 32.25800, 32.17300, 32.10600, 32.04200,Selling, 32.76700, 32.62500, 32.60700, 32.55300, 32.46700, 32.37800, 32.29300, 32.22600, 32.16000,\r\n" +
"20071022, USD, Buying, 32.22500, 32.52500, 32.50600, 32.42700, 32.35600, 32.27100, 32.18600, 32.12800, 32.06000,Selling, 32.76700, 32.62500, 32.60700, 32.54700, 32.47600, 32.39100, 32.30600, 32.24800, 32.18500,\r\n" +
"20071023, USD, Buying, 32.23000, 32.53000, 32.51100, 32.43500, 32.35700, 32.27300, 32.19800, 32.13200, 32.06100,Selling, 32.77200, 32.63000, 32.61200, 32.55500, 32.47700, 32.39300, 32.31800, 32.25200, 32.18100,\r\n" +
"20071024, USD, Buying, 32.21500, 32.51500, 32.49600, 32.42500, 32.34400, 32.25400, 32.18200, 32.12100, 32.04400,Selling, 32.75700, 32.61500, 32.59700, 32.54400, 32.46400, 32.37400, 32.30200, 32.24100, 32.16300,\r\n" +
"20071025, USD, Buying, 32.14000, 32.44000, 32.42100, 32.34900, 32.26500, 32.18500, 32.10700, 32.04500, 31.97500,Selling, 32.68200, 32.54000, 32.52300, 32.46900, 32.38500, 32.30500, 32.22700, 32.16500, 32.09800,\r\n" +
"20071026, USD, Buying, 32.10500, 32.40500, 32.38600, 32.31400, 32.23300, 32.15200, 32.07900, 32.01000, 31.94300,Selling, 32.64700, 32.50500, 32.48800, 32.43400, 32.35200, 32.27200, 32.19900, 32.13000, 32.06300,\r\n" +
"20071029, USD, Buying, 32.04000, 32.34000, 32.32100, 32.25300, 32.17300, 32.08800, 32.02500, 31.96500, 31.88700,Selling, 32.58200, 32.44000, 32.42200, 32.37200, 32.29300, 32.20800, 32.14500, 32.08500, 32.00700,\r\n" +
"20071030, USD, Buying, 32.05500, 32.35500, 32.33600, 32.26300, 32.18500, 32.10600, 32.03000, 31.96000, 31.89000,Selling, 32.59700, 32.45500, 32.43800, 32.38300, 32.30500, 32.22600, 32.15000, 32.08000, 32.01000,\r\n" +
"20071031, USD, Buying, 32.06000, 32.36000, 32.34100, 32.27200, 32.19000, 32.11200, 32.04300, 31.96500, 31.91000,Selling, 32.60200, 32.46000, 32.44300, 32.39100, 32.31000, 32.23200, 32.16300, 32.08500, 32.03000,\r\n" +
"20071101, USD, Buying, 32.03500, 32.33500, 32.31400, 32.25000, 32.16100, 32.09200, 32.02500, 31.95200, 31.88200,Selling, 32.57700, 32.43500, 32.41600, 32.37000, 32.28100, 32.21200, 32.14500, 32.07200, 32.00200,\r\n" +
"20071102, USD, Buying, 32.06000, 32.36000, 32.34200, 32.27500, 32.18900, 32.10700, 32.05000, 31.98000, 31.91200,Selling, 32.60200, 32.46000, 32.44300, 32.39400, 32.30800, 32.22400, 32.17000, 32.10000, 32.03200,\r\n" +
"20071105, USD, Buying, 32.05500, 32.35500, 32.33700, 32.27000, 32.18900, 32.10400, 32.04500, 31.97900, 31.90600,Selling, 32.59700, 32.45500, 32.43900, 32.39000, 32.30800, 32.22400, 32.16500, 32.09900, 32.02600,\r\n" +
"20071106, USD, Buying, 32.05000, 32.35000, 32.33200, 32.26200, 32.18800, 32.10000, 32.03400, 31.97000, 31.91000,Selling, 32.59200, 32.45000, 32.43300, 32.38100, 32.30700, 32.22000, 32.15400, 32.09000, 32.03000,\r\n" +
"20071107, USD, Buying, 32.01000, 32.31000, 32.29200, 32.22400, 32.14500, 32.06100, 31.99700, 31.93300, 31.86800,Selling, 32.55200, 32.41000, 32.39400, 32.34300, 32.26400, 32.18100, 32.11700, 32.05200, 31.98800,\r\n" +
"20071108, USD, Buying, 31.95000, 32.25000, 32.23200, 32.16600, 32.08000, 32.00800, 31.93900, 31.87100, 31.81100,Selling, 32.49200, 32.35000, 32.33400, 32.28600, 32.20000, 32.12800, 32.05900, 31.99100, 31.93100,\r\n" +
"20071109, USD, Buying, 31.91500, 32.21500, 32.19700, 32.13200, 32.04500, 31.97200, 31.90400, 31.83800, 31.77500,Selling, 32.45700, 32.31500, 32.29900, 32.25200, 32.16400, 32.09200, 32.02400, 31.95700, 31.89500,\r\n" +
"20071112, USD, Buying, 31.93500, 32.23500, 32.21700, 32.15200, 32.06500, 31.98900, 31.92000, 31.86000, 31.79500,Selling, 32.47700, 32.33500, 32.31800, 32.27000, 32.18500, 32.10900, 32.04000, 31.98000, 31.91500,\r\n" +
"20071113, USD, Buying, 31.95000, 32.25000, 32.22900, 32.16200, 32.08000, 32.00700, 31.93000, 31.87200, 31.80900,Selling, 32.49200, 32.35000, 32.33100, 32.28200, 32.19900, 32.12400, 32.05000, 31.99200, 31.92900,\r\n" +
"20071114, USD, Buying, 31.93000, 32.23000, 32.21200, 32.14200, 32.05800, 31.97400, 31.91100, 31.84700, 31.78100,Selling, 32.47200, 32.33000, 32.31300, 32.26200, 32.17800, 32.09400, 32.04100, 31.96700, 31.90100,\r\n" +
"20071115, USD, Buying, 31.94500, 32.24500, 32.22700, 32.15700, 32.07300, 31.98900, 31.92600, 31.86200, 31.79600,Selling, 32.48700, 32.34500, 32.32800, 32.27700, 32.19300, 32.10900, 32.05600, 31.98200, 31.91600,\r\n" +
"20071116, USD, Buying, 31.98500, 32.28500, 32.26700, 32.19700, 32.11300, 32.02900, 31.96600, 31.90200, 31.83600,Selling, 32.52700, 32.38500, 32.36800, 32.31700, 32.23300, 32.14900, 32.09600, 32.02200, 31.95600,\r\n" +
"20071119, USD, Buying, 32.02000, 32.32000, 32.30200, 32.23200, 32.14800, 32.06400, 32.00100, 31.93700, 31.87100,Selling, 32.56200, 32.42000, 32.40300, 32.35200, 32.26800, 32.18400, 32.13100, 32.05700, 31.99100,\r\n" +
"20071120, USD, Buying, 32.01000, 32.31000, 32.29100, 32.21800, 32.12600, 32.04000, 31.97500, 31.90500, 31.84500,Selling, 32.55200, 32.41000, 32.39300, 32.33800, 32.24600, 32.16000, 32.09500, 32.02500, 31.96500,\r\n" +
"20071121, USD, Buying, 31.99500, 32.29500, 32.27600, 32.20300, 32.10700, 32.02000, 31.95900, 31.89100, 31.81000,Selling, 32.53700, 32.39500, 32.37700, 32.32300, 32.22700, 32.14000, 32.07900, 32.01100, 31.93000,\r\n" +
"20071122, USD, Buying, 32.00000, 32.30000, 32.28100, 32.20800, 32.11200, 32.02500, 31.96400, 31.89600, 31.81500,Selling, 32.54200, 32.40000, 32.38200, 32.32800, 32.23200, 32.14500, 32.08400, 32.01600, 31.93500,\r\n" +
"20071123, USD, Buying, 31.98000, 32.28000, 32.26000, 32.18800, 32.08200, 31.99500, 31.92500, 31.86000, 31.76000,Selling, 32.52200, 32.38000, 32.36200, 32.30800, 32.20200, 32.11500, 32.04500, 31.98000, 31.89500,\r\n" +
"20071126, USD, Buying, 31.97000, 32.27000, 32.25000, 32.17800, 32.07300, 31.97700, 31.90700, 31.82500, 31.75300,Selling, 32.51200, 32.37000, 32.35200, 32.29700, 32.19200, 32.09500, 32.02700, 31.94500, 31.87200,\r\n" +
"20071127, USD, Buying, 31.98000, 32.28000, 32.26000, 32.18200, 32.08600, 31.98800, 31.91400, 31.84000, 31.76000,Selling, 32.52200, 32.38000, 32.36200, 32.30200, 32.20600, 32.10500, 32.03400, 31.96000, 31.89000,\r\n" +
"20071128, USD, Buying, 31.98500, 32.28500, 32.26600, 32.19200, 32.09000, 32.00000, 31.92900, 31.85000, 31.78700,Selling, 32.52700, 32.38500, 32.36700, 32.31200, 32.21000, 32.12000, 32.04900, 31.97000, 31.90700,\r\n" +
"20071129, USD, Buying, 31.96000, 32.26000, 32.23800, 32.14700, 32.05000, 31.96700, 31.89000, 31.80500, 31.70000,Selling, 32.50200, 32.36000, 32.34000, 32.26700, 32.17000, 32.08700, 32.01000, 31.92500, 31.88000,\r\n" +
"20071130, USD, Buying, 31.91500, 32.21500, 32.19400, 32.10000, 31.99400, 31.91300, 31.83500, 31.76000, 31.65000,Selling, 32.45700, 32.31500, 32.29600, 32.22000, 32.12200, 32.03300, 31.95500, 31.88000, 31.82000,\r\n" +
"20071203, USD, Buying, 31.96000, 32.26000, 32.23900, 32.14500, 32.04500, 31.96000, 31.88300, 31.81200, 31.70500,Selling, 32.50200, 32.36000, 32.34100, 32.26500, 32.17500, 32.09000, 32.00300, 31.93100, 31.86500,\r\n" +
"20071204, USD, Buying, 31.96000, 32.26000, 32.24000, 32.14600, 32.04500, 31.97800, 31.89400, 31.83000, 31.75500,Selling, 32.50200, 32.36000, 32.34200, 32.26600, 32.16500, 32.09800, 32.01400, 31.95000, 31.89500,\r\n" +
"20071205, USD, Buying, 31.96500, 32.26500, 32.24500, 32.15800, 32.06000, 31.99300, 31.91200, 31.84600, 31.77500,Selling, 32.50700, 32.36500, 32.34700, 32.27800, 32.18000, 32.11000, 32.03200, 31.96600, 31.89500,\r\n" +
"20071206, USD, Buying, 31.97000, 32.27000, 32.25000, 32.16200, 32.07500, 32.00000, 31.93200, 31.84800, 31.77700,Selling, 32.51200, 32.37000, 32.35200, 32.28300, 32.19500, 32.12000, 32.05200, 31.96800, 31.89700,\r\n" +
"20071207, USD, Buying, 31.96000, 32.26000, 32.24000, 32.15200, 32.06200, 31.98500, 31.90700, 31.83500, 31.75500,Selling, 32.50200, 32.36000, 32.34200, 32.27200, 32.18200, 32.10500, 32.03700, 31.95500, 31.89500,\r\n" +
"20071210, USD, Buying, 31.98000, 32.28000, 32.26100, 32.16800, 32.08700, 32.00400, 31.92300, 31.84500, 31.77100,Selling, 32.52200, 32.38000, 32.36200, 32.28500, 32.20700, 32.12400, 32.04300, 31.96500, 31.90500,\r\n" +
"20071211, USD, Buying, 31.99000, 32.29000, 32.27100, 32.18200, 32.09500, 32.01200, 31.93700, 31.86200, 31.78200,Selling, 32.53200, 32.39000, 32.37200, 32.30200, 32.21500, 32.13200, 32.05700, 31.98200, 31.91200,\r\n" +
"20071212, USD, Buying, 32.02000, 32.32000, 32.30300, 32.22000, 32.13000, 32.05400, 31.97200, 31.89600, 31.82500,Selling, 32.56200, 32.42000, 32.40400, 32.34000, 32.25000, 32.17400, 32.09200, 32.01600, 31.95000,\r\n";
function bodyonload(){
	//getData(getURL('USD'));
}
</script>
</head>
<body onload="bodyonload()">
	<textarea cols="80" rows="20" id="outdata"></textarea>
</body>
</html>
